<?php
	header("Content-Type: text/html;charset=utf-8");
	include("../_judge.php");
	include("../../function/function.php");
	
	$action = chkstr(trim($_REQUEST['action']));
	$guan_name = chkstr(trim($_REQUEST['guan_name']));
	$id = chkstr(trim($_REQUEST['id']));

	if($action == "addbigclass"){

		$mysql = new sqlstr("kboy_guan"); 
		$news_sql = $mysql -> insertSql();
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo re("newsmanage.php#Anchor".$$last_id);
		}else{
			echo erro("服务器内部错误");
		}
	
	}elseif($action == "add"){
		if(strlen($id)<1){
			echo erro("ID不能为空");
		}
		if(!is_numeric($id)){
			echo erro("ID错误");
		}
		if(getNewsNums("kboy_bigclass","id=$id")<1){
			echo erro("至少选择一条信息");
		}
	
		$mysql = new sqlstr("kboy_bigclass"); 
		$mysql -> set("pid",$id,true);
		$mysql -> set("bigclass_style",3,true);
		$news_sql = $mysql -> insertSql();
		$news_res = mysql_query($news_sql);
		if($news_res){
			$last_id = mysql_insert_id();
			mysql_query("update kboy_bigclass set bigclass_order=$last_id where id=$last_id");
			echo re("newsmanage.php#Anchor".$last_id);
		}else{
			echo erro("服务器内部错误");
		}
	}elseif($action == "edit"){
		if(strlen($id)<1){
			echo erro("ID不能为空");
		}
		if(!is_numeric($id)){
			echo erro("ID错误");
		}
		if(getNewsNums("kboy_bigclass","id=$id")<1){
			echo erro("至少选择一条信息");
		}

		$mysql = new sqlstr("kboy_guan"); 
		$mysql -> set("active_name",$guan_name);
		$news_sql = $mysql -> updateSql("gid=$id");
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo re("newsmanage.php#Anchor".$id);
		}else{
			echo erro("服务器内部错误");
		}
		
	}elseif($action == "del"){
		if(strlen($id)<1){
			echo erro("ID不能为空");
		}
		if(!is_numeric($id)){
			echo erro("ID错误");
		}
		if(getNewsNums("kboy_guan","gid=$id")<1){
			echo erro("至少选择一条信息");
		}
		$mysql = new sqlstr("kboy_guan"); 
		$news_sql = $mysql -> deleteSql("gid = $id");
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo re("newsmanage.php");
		}else{
			echo erro("服务器内部错误");
		}
	}else{
		echo erro("参数错误");
	}
	
?>
